import { ImageInfo } from "@/engine/types/ImageSwitcher";
import { WatchStopHandle } from "vue";

/**
 * 通用菜单类型
 */
export enum ShapeKeyEnum {
  SimulationFrame = 'SimulationFrame', // 窗口
  SimulationPanel="SimulationPanel", // 面板
  SimulationButton="SimulationButton", // 按钮
  SimulationLabel="SimulationLabel", // 文本
  SimulationTextField="SimulationTextField", // 输入框
  ImageShape="ImageShape", // 图片
  AttachedFile="AttachedFile",
}

export type ADCUICoreNode = {
  modelId: string,
  propertyId: string,
  propertyData: UIPropertyData,
  style:{
    width: number,
    height: number,
    x: number,
    y: number,
    color: string
    fontSize: number,
    fontWeight: number,
    fontFamily: string,
    background: string,
    border: string,
    textAlign: string,
    fontStyle: string,
  },
  propertyPath: string,
  showText?:string,
  shapeKey: ShapeKeyEnum,
  children: ADCUICoreNode[],
  valueType: UIDataType,
  icon: string,
  objectId: string,
  imageInfo?: ImageInfo,
}

export type MenuItem = {
  label?: string;
  value: string;
  children?: MenuItem[];
  disabled?: boolean;
  icon?: string
  isHR?: boolean
  active?: boolean
  [p: string]: any // 菜单可以携带其他信息
};

export interface InstancetableCellMarkDto {
  color: string;
  msg: string;
  instanceId: string;
  definingfeatureId: string;
}

export type HeaderMenuOption = {
  comp: any // 插入的组件
}

export class Theme {
  color = "";
  focusColor = "";
  disabledColor = "";
  constructor(theme: ThemeColor) {
    this.color = theme.color;
    this.focusColor = theme.focusColor;
    this.disabledColor = theme.disabledColor;
  }
}

export type ThemeColor = {
  color: string;
  focusColor: string;
  disabledColor: string;
}

/**
 * 用于支持自定义 UI 的类型
 */
export type IPCMsgContent = {
  api: string,
  data: any,
};

export enum UIDataType {
  Boolean = "Boolean",
  String = "String",
  Real = "Real",
  Integer = "Integer",
  Enumeration = "Enumeration",
  UnlimitedNatural = "UnlimitedNatural",
  Object = "Object",
  Any = "any"
}

export enum UIDataColor {
  White = "white",
  Green = "green",
  Red = "red",
  Pink = "pink",
}

export type UIPropertyData = {
  value: string,
  color: UIDataColor,
  valueType: UIDataType,
};

export type UIPropertyDataNode = {
  parentObjectId: string | null, // 由于一个属性实例可能被多个属性作为部件属性引用，此值可能不唯一，但我们取其中任意一个作为更新凭据
  datas: UIPropertyData[],
  valueType: UIDataType,
  propertyId: string,
  properties: Map<string, UIPropertyDataNode>[],
  refToUpdate: Map<number, UIPropertyData[]>,
  refToUpdateByIndex: Map<number, UIPropertyData>[],
  uiUpdateHandlers: Map<number, WatchStopHandle>,
  refCnt: number
};

export type UICoreUpdateData = {
  objectId: string,
  properties: {
    propertyId: string,
    valueType: UIDataType,
    values: string[]
  }[]
};

export type UIStatusInfo = {
  color: UIDataColor,
  shortMsg: string,
  fullMsg: string,
};

export type UIConstraintStatusData = {
  objectId: string,
  properties: {
    propertyId: string,
    status: UIStatusInfo
  }[]
}[];
